package com.newbe.kaptcha.controller;

import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.newbe.kaptcha.utils.PhotoCodeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
public class OrderController {

	@Autowired
	private DefaultKaptcha defaultKaptcha;

	// 首页
	@RequestMapping("/")
	public String index() {
		return "index";
	}

	// 查询订单
	@RequestMapping("/showOrder")
	public String showOrder() {
		return "showOrder";
	}

	// 添加订单
	@RequestMapping("/addOrder")
	public String addOrder() {
		return "addOrder";
	}

	// 修改订单
	@RequestMapping("/updateOrder")
	public String updateOrder() {
		return "updateOrder";
	}

	// 删除订单
	@RequestMapping("/deleteOrder")
	public String deleteOrder() {
		return "deleteOrder";
	}

   //自定义登录界面
   @RequestMapping("/login")
	String login() {
		return "login";
	}


	//图形验证码生成
	@GetMapping("/defaultKaptcha")
	public String defaultKaptcha( HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception{
		return PhotoCodeUtil.createCode(defaultKaptcha,httpServletRequest, httpServletResponse);
	}
}
